package com.atguigu.oss.controller;

import com.atguigu.oss.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * OSS文件上传控制器
 * @author daygods
 * @since 2025-07-13
 */
@RestController
@RequestMapping("/api/oss/fileoss")
@CrossOrigin
public class OssController {

    @Autowired
    private OssService ossService;

    /**
     * 上传头像到OSS
     */
    @PostMapping("/upload")
    public String uploadOssFile(@RequestParam("file") MultipartFile file) {
        String url = ossService.uploadFileAvatar(file);
        return url;
    }
}